<?php
class mpagescontent extends CI_Model{
	var $pages = "pages_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_page,$region_page,$file_page,$description_page)
	{
		$this->id_page= $id_page;
		$this->region_page= $region_page;
		$this->file_page= $file_page;
		$this->description_page= $description_page;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->pages, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->pages);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_page'=>$this->id_page,
			'region_page'=>$this->region_page,
			'file_page'=>$this->file_page,
			'description_page'=>$this->description_page
		);
		return $this->db->insert($this->pages, $arrayData);
	}
	
	function update($id_page)
	{
		$arrayData = array(
			'region_page'=>$this->region_page,
			'file_page'=>$this->file_page,
			'description_page'=>$this->description_page
		);
		$this->db->where('id_page', $id_page);
		return $this->db->update($this->pages, $arrayData);
	}
        
	function remove($id_page)
	{
		$this->db->where('id_page', $id_page);
		return $this->db->delete($this->pages);
	}	
	
	function detail($id_page)
	{
		$this->db->where('id_page', $id_page);
		$query = $this->db->get($this->pages);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('file_page',$name);
		$query = $this->db->get($this->pages);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($region_page)
	{
		$this->db->where('region_page', $region_page);
		$query = $this->db->get($this->pages);	
		return $query->result_array();
	}
}
?>